import allure
from selenium.webdriver.common.by import By

from wewrok_app_po.Base.wework_app import *
from wewrok_app_po.Page.addresslist import AddressListPage
from wewrok_app_po.Page.work_staging import WorkStaging


class MainPage(WeWorkApp):
    # 页面元素定义为私有类属性
    _CONTACT_BTN = By.XPATH, "//*[@text = '通讯录']"
    _WORK_STAGING = By.XPATH, "//*[@text='工作台']"

    # def __init__(self, driver: WebDriver):
    #     super().__init__(driver)
    #     self.driver = driver
    def goto_address_list(self):
        # 点击通讯录按钮
        # 找到通讯录点击通讯录
        with allure.step("点击通讯录按钮"):
            self.find_and_click(* self._CONTACT_BTN)

        # 跳转到通讯录页面
        return AddressListPage(self.driver)

    def goto_work_staging(self):
        # 点击工作台
        with allure.step("点击工作台按钮"):
            self.find_and_click(*self._WORK_STAGING)
        return WorkStaging(self.driver)


